package com.bing.autoconfig;

import com.bing.animal.Cat;
import com.bing.animal.Dog;
import com.bing.anotation.Bing;
import com.bing.scanner.BingScanner;
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
import org.springframework.beans.factory.support.BeanNameGenerator;
import org.springframework.beans.factory.support.GenericBeanDefinition;
import org.springframework.context.annotation.ImportBeanDefinitionRegistrar;
import org.springframework.core.type.AnnotationMetadata;

public class AnimalImportBeanDefinitionRegistrar implements ImportBeanDefinitionRegistrar {

    @Override
    public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {

        //extracted(registry);
        extracted(importingClassMetadata, registry);

    }


    private void extracted(BeanDefinitionRegistry registry) {
        GenericBeanDefinition gbdCat = new GenericBeanDefinition();
        gbdCat.setBeanClass(Cat.class);

        registry.registerBeanDefinition("cat", gbdCat);
    }


    private void extracted(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {


        //定义Dog
        GenericBeanDefinition gbdDog = new GenericBeanDefinition();
       // gbdDog.getConstructorArgumentValues().addGenericArgumentValue(registry;
        gbdDog.setBeanClass(AnimalFactoryBean.class);
        registry.registerBeanDefinition("dog", gbdDog);
    }


}
